# -*- coding:utf-8 -*-
# @Author: shenyuyu
# @Time: 2023/6/15 15:16
# @File: test2.py

import os


def move_file(path):
    files = os.listdir(path)
    global c, a, b, n
    a = c + a
    for i in files:
        if os.path.isfile(a + "/" + i):
            os.replace(path + "/" + i, (path + "/" + i).replace(n, b))
        else:
            if os.path.exists(b + i):
                pass
            else:
                os.mkdir(b + i)
            c = a + "/"
            a = i
            move_file(c + a)




a = "test"
n = "test/"
b = "a/b/"
c = ""
move_file(a)
listdir = os.listdir(n)
for i in listdir:
    os.remove(n + i)